---
import { getEntry, render } from "astro:content";
import Markdown from "@components/misc/Markdown.astro";
import I18nKey from "@i18n/i18nKey";
import { i18n } from "@i18n/translation";
import MainGridLayout from "@layouts/MainGridLayout.astro";

interface Props {
	title?: string;
}

const props = Astro.props;
const title = props.title || i18n(I18nKey.projects);

const projectPost = await getEntry("spec", "project");

if (!projectPost) {
	throw new Error("Projects content not found");
}

const { Content } = await render(projectPost);
---

<MainGridLayout title={title} description={title}>
	<div class="flex w-full rounded-[var(--radius-large)] overflow-hidden relative min-h-32">
		<div class="card-base z-10 px-9 py-6 relative w-full">
			<Markdown class="mt-2">
				<Content />
			</Markdown>
		</div>
	</div>
</MainGridLayout>

<style>
/* 项目列表样式 */
h2 + ul {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
  padding-left: 0;
  list-style-type: none;
}

/* 项目卡片样式 - 增强版 */
h2 + ul li {
  background-color: var(--bg-card);
  border-radius: 12px;
  padding: 1.75rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}

/* 卡片装饰元素 */
h2 + ul li::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
}

/* 卡片悬浮效果 */
h2 + ul li:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  border-color: var(--primary-light);
}

/* 可折叠项目样式 */
h2 + ul li details {
  width: 100%;
}

/* 折叠标题样式 - 增强版 */
h2 + ul li details summary {
  cursor: pointer;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-primary);
  padding: 1rem 1.25rem;
  margin-bottom: 0;
  border: none;
  border-radius: 8px;
  background-color: rgba(var(--primary-rgb), 0.05);
  transition: all 0.3s ease;
  list-style-type: none;
  outline: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  overflow: hidden;
}

/* 移除默认箭头 */
h2 + ul li details summary::-webkit-details-marker {
  display: none;
}

/* 悬浮效果增强 */
h2 + ul li details summary:hover {
  color: var(--primary);
  background-color: rgba(var(--primary-rgb), 0.1);
  transform: translateX(4px);
}

/* 聚焦效果 */
h2 + ul li details summary:focus {
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.2);
}

/* 自定义箭头 - 美化版 */
h2 + ul li details summary::after {
  content: '⌄';
  font-size: 1.2rem;
  color: var(--primary);
  font-weight: bold;
  transition: transform 0.3s ease, color 0.3s ease;
  line-height: 1;
}

/* 展开时旋转箭头 */
h2 + ul li details[open] summary::after {
  transform: rotate(180deg) translateY(2px);
}

/* 展开状态下的summary样式 */
h2 + ul li details[open] summary {
  background-color: rgba(var(--primary-rgb), 0.1);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  margin-bottom: 0;
}

/* 展开内容容器样式 */
h2 + ul li details > div, 
h2 + ul li details > p, 
h2 + ul li details > ul {
  background-color: var(--bg-card);
  border: 1px solid rgba(var(--primary-rgb), 0.2);
  border-top: none;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
  padding: 1.25rem;
  margin-top: 0;
}

/* 项目标题样式 */
h2 + ul li h3 {
  margin-top: 0.5rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
  font-size: 1.35rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* 项目描述样式 */
h2 + ul li p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-size: 1rem;
  line-height: 1.6;
}

/* 分隔线样式 */
h2 + ul li ul {
  margin: 1.25rem 0;
  padding-left: 1.25rem;
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
}

/* 项目信息样式 */
h2 + ul li ul li {
  background: none;
  padding: 0;
  margin-bottom: 0.5rem;
  border: none;
  box-shadow: none;
  border-radius: 0;
  transform: none;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

h2 + ul li ul li::before {
  content: '•';
  color: var(--primary);
  font-weight: bold;
  position: static;
  width: auto;
  height: auto;
  background: none;
}

/* 项目链接样式 */
h2 + ul li a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s ease;
  font-weight: 500;
  display: inline-block;
  padding: 0.25rem 0;
}

h2 + ul li a:hover {
  color: var(--primary-light);
  text-decoration: underline;
}

/* 特性列表样式 */
h2 + ul li p strong {
  color: var(--text-primary);
  font-weight: 600;
  margin-right: 0.5rem;
}

/* GitHub卡片样式调整 */
h2 + ul li .github-card {
  margin-top: 1.25rem;
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
}

/* 响应式调整 */
@media (max-width: 768px) {
  h2 + ul {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  h2 + ul li {
    padding: 1.5rem;
  }
  
  h2 + ul li h3 {
    font-size: 1.25rem;
  }
  
  h2 + ul li details summary {
    font-size: 1.15rem;
    padding: 0.75rem 1rem;
  }
  
  h2 + ul li details > div, 
  h2 + ul li details > p, 
  h2 + ul li details > ul {
    padding: 1rem;
  }
}
</style>